using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using Module.DataAccess;
using Module.EntitiesInfo;

namespace Module.BusinessLogic
{
    public class CMSGalleryBL
	{
		
		public static int Insert(CMSGalleryInfo cMSGalleryInfo)
		{
			try
			{
                DataCach.DataCach cache = new DataCach.DataCach();
                cache.RemoveAll();
				return new CMSGalleryDB().Insert(cMSGalleryInfo);
			}
			catch (Exception ex)
			{
				throw;
			}

		}

        public static void Update(CMSGalleryInfo cMSGalleryInfo)
		{
			try
			{
				new CMSGalleryDB().Update(cMSGalleryInfo);
                DataCach.DataCach cache = new DataCach.DataCach();
                cache.RemoveAll();
			}
			catch (Exception ex)
			{
				throw;
			}

		}

        public static void Delete(int galleryId)
		{
			try
			{
				new CMSGalleryDB().Delete(galleryId);
                DataCach.DataCach cache = new DataCach.DataCach();
                cache.RemoveAll();
			}
			catch (Exception ex)
			{
				throw;
			}

		}

        public static List<CMSGalleryInfo> Select(int type, string param_1, string param_2)
        {
            try
            {
                return ObjectHelper.FillCollection<CMSGalleryInfo>(new CMSGalleryDB().Select(type, param_1, param_2));
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        public static DataTable SelectTbl(int? type, string para_1, string para_2)
        {
            try
            {
                return new CMSGalleryDB().SelectTbl(type, para_1, para_2);
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        public static DataTable GetAll(int param, int type)
        {
            try
            {
                DataCach.DataCach cache = new DataCach.DataCach();
                string strCache = param + "_" + type + "{BFE31F0B-AD48-41F7-83CE-A5832F0B8D98}";
                DataTable dt = new DataTable();
                if (cache.GetCache(strCache) != null)
                {
                    dt = (DataTable)(cache.GetCache(strCache));
                    return dt;
                }
                dt = new CMSGalleryDB().GetAll(param, type);
                if (dt != null && dt.Rows.Count > 0)
                {
                    cache.InsertCache(strCache, dt, Convert.ToDouble(ConfigurationSettings.AppSettings["timeCache"].ToString()));
                }
                return dt;                          
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static CMSGalleryInfo GetInfo(int id)
        {
            try
            {
                CMSGalleryInfo cmsGalleryInfo;
                cmsGalleryInfo = ObjectHelper.FillObject<CMSGalleryInfo>(new CMSGalleryDB().GetInfo(id));
                if (cmsGalleryInfo != null)
                    return cmsGalleryInfo;
                return null;
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static int GetCount(string keysearch, int zoneId, int status, DateTime starDatetime, DateTime endDatetime, int beginRow, int endRow)
        {
            try
            {
                return new CMSGalleryDB().GetCount(keysearch, zoneId, status, starDatetime, endDatetime, beginRow, endRow);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        public static DataTable Search(string keysearch, int zoneId, int status, DateTime starDatetime, DateTime endDatetime, int beginRow, int endRow, string orderByColumn)
        {
            try
            {
                return new CMSGalleryDB().Search(keysearch, zoneId, status, starDatetime, endDatetime, beginRow, endRow, orderByColumn);
            }
            catch (Exception ex)
            {
                throw;
            }

        }
        public static void UpdateStatus(int galleryId, int status, int param)
        {
            try
            {
                new CMSGalleryDB().UpdateStatus(galleryId, status, param);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

	}
}
